package com.harry.martin_skill_master.application;

import android.app.Application;
import android.content.Context;

import androidx.appcompat.app.AppCompatDelegate;

import com.facebook.drawee.backends.pipeline.Fresco;

/**
 * @author Martin-harry
 * @date 2021/8/10
 * @address
 * @Desc 全局初始化
 */
public class MyApp extends Application {

    private static Context context;
    private static MyApp instance;

    @Override
    public void onCreate() {
        super.onCreate();

        Fresco.initialize(this);
        instance = this;
        context = getApplicationContext();

        /**
         * 默认设置一直使用夜间模式
         *
         * 这里AppCompatDelegate.setDefaultNightMode()方法可以接受的参数值有4个：
         * MODE_NIGHT_NO. Always use the day (light) theme(一直应用日间(light)主题).
         * MODE_NIGHT_YES. Always use the night (dark) theme(一直使用夜间(dark)主题).
         * MODE_NIGHT_AUTO. Changes between day/night based on the time of day(根据当前时间在day/night主题间切换).
         * MODE_NIGHT_FOLLOW_SYSTEM(默认选项). This setting follows the system's setting, which is essentially MODE_NIGHT_NO(跟随系统，通常为
         MODE_NIGHT_NO).
         */
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    }

    public static MyApp getInstance() {
        return instance;
    }

    public static Context getAppContext() {
        return context;
    }
}
